<?php
// @formatter:off
/**
 * @file c.registeruser.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-07-05 14:30:06 +0000 (Fri, 05 Jul 2013) $
 *
 * $Id: c.registeruser.php 89 2013-07-05 14:30:06Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.1/themes/default/controlers/contents/c.registeruser.php $
 */
// @formatter:on

if($wcProfile->allowedTo(WC_PERM_USER_REGISTER)) {
	global $wcUsersHolder;

	if(!$wcSession->isLogged()) {
		$wcThemeAssigns["PATH"] = "Sign Up";
		$wcThemeAssigns["ACTIONCONTENT"] = "/contents/c.registeruser.html";

		startCaptcha();

		if(isset($_REQUEST["activate"]) && isset($_REQUEST["user"])) {
			$hash = trim($_REQUEST["activate"]);
			$wcUser = new WCUser();
			$wcUser->load(trim($_REQUEST["user"]));

			if($wcUser && $wcUser->hash_register == $hash) {
				$wcThemeAssigns["ACTIVATION"] = $wcUser->id();
				$wcUser->activate();
			} else {
				$wcThemeAssigns["error-string"] = "Requested user is already activated";
				require "{$this->_themeRoot}/controlers/contents/c.500.php";
			}
		}
	} else {
		$wcThemeAssigns["error-string"] = "A user is already logged in";
		require "{$this->_themeRoot}/controlers/contents/c.500.php";
	}
} else {
	$wcThemeAssigns["error-string"] = "You're not allowed to register as a new user";
	require "{$this->_themeRoot}/controlers/contents/c.403.php";
}
?>